using System;
using System.IO;

namespace SynoManager.DownloadStation
{
    [DownloadStationPlugin("Torrent File Handler", "Provides access to torrent files", "SynoManager Team", "1.0.0.0")]
    public class DefaultTorrentFileHandler : IDownloadFileHandlerPlugin
    {
        public string Filter
        {
            get { return "*.torrent"; }
        }

        public string FileTypeDescription
        {
            get { return "Torrent Files"; }
        }

        public bool IncludeInAllFiles
        {
            get { return true; }
        }

        public void Process(ProcessFileArgs args)
        {
            var result = service.redirector.AddFile(args.Path);
            args.Processed = result.success;
        }

        public void CreateTask(string path)
        {
            throw new NotImplementedException();
        }

        public bool CanProcess(string path)
        {
            if (!File.Exists(path))
                return false;

            if (Path.GetExtension(path) != ".torrent")
                return false;

            return true;
        }

        private DownloadStationService service;
        public void Initialize(DownloadStationService service)
        {
            this.service = service;
        }

        public void Close()
        {
            
        }
    }
}